<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			body{text-align: center;}
		</style>
	</head>
	<body>
		<select id="choose">
			<option value="">请选择大小</option>
			<option value="b">大</option>
			<option value="a">小</option>
		</select>
		<br>
		<img src="../img/1.jpg" id="img_id" >
		<br>
		<button type="button" onclick="begin(event);">开始</button>
	</body>
	<script type="text/javascript">
	
		function begin(event){
			var choose = document.getElementById('choose').value;
			if (choose=="") {
				alert('请选择:');	
				 return;
			}
			var aa = event.target;
			
			aa.disabled='disabled';
			console.log(aa.disabled)
			var count = 0;
			var num = 0;
			var result = "";
			var interval=setInterval(function(){
				if (count==10) {
					result=num<=3 ?'a':'b';
					if (result==choose) {
						alert('选择正确')
					}else{
						alert('选择错误')
					}
					clearInterval(interval);
					aa.innerText='重来';
					aa.disabled="";
					return;
				}
				num = getnum();
				// console.log(num)
				document.getElementById('img_id').src='../img/'+num+'.jpg';
				// console.log(document.getElementById('img_id'))
				count++;
			},100)
		}
		function getnum(){
			var num = 0;
			while (true){
				num = Math.floor(Math.random()*10);
				if (num>0 && num<7) {
					break;
				}
			}
			return num;
		}
	</script>
</html>
